package uit.edu.upload2server;

import java.io.IOException;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.xmlpull.v1.XmlPullParserException;

//import android.util.Log;

public class Webservices {
	
	public static String getUserList() throws IOException, XmlPullParserException{
		String list = "";
		String SOAP_ACTION = "http://10.0.2.2:8080/ServerWeb/services/Service/GetUserList";
		String METHOD_NAME = "GetUserList";
		String NAMESPACE = "http://vn.edu.uit";
		String URL = "http://10.0.2.2:8080/ServerWeb/services/Service?wsdl";	
		SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
		envelope.setOutputSoapObject(request);
		AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);		
		androidHttpTransport.call(SOAP_ACTION, envelope);		
		SoapPrimitive result = (SoapPrimitive) envelope.getResponse();
		list = result.toString();								
		return list;
	}
	public static String getHomePath() throws IOException, XmlPullParserException{
		String SOAP_ACTION = "http://10.0.2.2:8080/ServerWeb/services/Service/getHomePath";
		String METHOD_NAME = "getHomePath";
		String NAMESPACE = "http://vn.edu.uit";
		String URL = "http://10.0.2.2:8080/ServerWeb/services/Service?wsdl";	
		SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
		envelope.setOutputSoapObject(request);
		AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);		
		androidHttpTransport.call(SOAP_ACTION, envelope);		
		SoapPrimitive result = (SoapPrimitive) envelope.getResponse();	
		return result.toString();
	}	

}
